Use it to replace x86-specific early_boot boolean variable.
Also use it to detect suspend/resume case during cpu offline/online
to avoid unnecessarily breaking vcpu and cpupool affinities.
Signed-off-by: Keir Fraser <keir@xen.org>
Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
/* Hide UART from DOM0 if we're using it */
serial_endboot();
+ system_state = SYS_STATE_active;
+
domain_unpause_by_systemcontroller(dom0);
/* Switch on to the dynamically allocated stack for the idle vcpu
if ( !spin_trylock(&pm_lock) )
return -EBUSY;
+ BUG_ON(system_state != SYS_STATE_active);
+ system_state = SYS_STATE_suspend;
+
printk(XENLOG_INFO "Preparing system for ACPI S%d state.\n", state);
freeze_domains();
acpi_dmar_reinstate();
if ( (error = disable_nonboot_cpus()) )
+ {
+ system_state = SYS_STATE_resume;
goto enable_cpu;
+ }
cpufreq_del_cpu(0);
if ( (error = device_power_down()) )
{
printk(XENLOG_ERR "Some devices failed to power down.");
+ system_state = SYS_STATE_resume;
goto done;
}
break;
}
+ system_state = SYS_STATE_resume;
+
/* Restore CR4 and EFER from cached values. */
cr4 = read_cr4();
write_cr4(cr4 & ~X86_CR4_MCE);
mtrr_aps_sync_end();
acpi_dmar_zap();
thaw_domains();
+ system_state = SYS_STATE_active;
spin_unlock(&pm_lock);
return error;
}
void free_xen_pagetable(void *v)
{
- if ( early_boot )
+ if ( system_state == SYS_STATE_early_boot )
return;
if ( is_xen_heap_page(virt_to_page(v)) )
s8 __read_mostly xen_cpuidle = -1;
boolean_param("cpuidle", xen_cpuidle);
-bool_t __read_mostly early_boot = 1;
-
cpumask_t __read_mostly cpu_present_map;
unsigned long __read_mostly xen_phys_start;
void *ret;
#ifdef __x86_64__
- if ( !early_boot )
+ if ( system_state != SYS_STATE_early_boot )
return mod ? mfn_to_virt(mod->mod_start) : NULL;
#endif
#endif
end_boot_allocator();
- early_boot = 0;
+ system_state = SYS_STATE_boot;
#if defined(CONFIG_X86_64)
vesa_init();
dmi_end_boot();
+ system_state = SYS_STATE_active;
+
domain_unpause_by_systemcontroller(dom0);
reset_stack_and_jump(init_done);
{
unsigned long mfn;
- if ( !early_boot )
+ if ( system_state != SYS_STATE_early_boot )
{
void *v = alloc_xenheap_page();
{
unsigned long mfn;
- if ( !early_boot )
+ if ( system_state != SYS_STATE_early_boot )
{
struct page_info *pg = alloc_domheap_page(NULL, 0);
unsigned int cpu = (unsigned long)hcpu;
int rc = 0;
+ if ( (system_state == SYS_STATE_suspend) ||
+ (system_state == SYS_STATE_resume) )
+ goto out;
+
switch ( action )
{
case CPU_DOWN_FAILED:
break;
}
+out:
return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
}
#ifndef COMPAT
+enum system_state system_state = SYS_STATE_early_boot;
+
int tainted;
xen_commandline_t saved_cmdline;
int ret = 0;
c = per_cpu(cpupool, cpu);
- if ( c == NULL )
+ if ( (c == NULL) || (system_state == SYS_STATE_suspend) )
return ret;
for_each_domain_in_cpupool ( d, c )
#include <xen/multiboot.h>
-extern bool_t early_boot;
extern unsigned long xenheap_initial_phys_start;
void early_cpu_init(void);
(__p >= _sinittext) && (__p < _einittext); \
})
+extern enum system_state {
+ SYS_STATE_early_boot,
+ SYS_STATE_boot,
+ SYS_STATE_active,
+ SYS_STATE_suspend,
+ SYS_STATE_resume
+} system_state;
+
#endif /* _LINUX_KERNEL_H */